package com.hui.qiniucloud.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 聊天会话实体
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("chat_session")
@Schema(description = "聊天会话实体")
public class ChatSession implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "会话ID，主键自增", example = "1")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @Schema(description = "用户ID", example = "1")
    private Long userId;

    @Schema(description = "角色ID，NULL表示无角色对话", example = "harry_potter")
    private String characterId;

    @Schema(description = "会话标题", example = "关于魔法的讨论")
    private String title;

    @Schema(description = "最后一条消息内容")
    private String lastMessage;

    @Schema(description = "消息数量", example = "10")
    private Integer messageCount;

    @Schema(description = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createdTime;

    @Schema(description = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedTime;

    @Schema(description = "逻辑删除标识：0-未删除，1-已删除")
    @TableLogic
    private Integer deleted;

    public ChatSession() {}

    public ChatSession(Long userId, String characterId, String title) {
        this.userId = userId;
        this.characterId = characterId;
        this.title = title;
        this.messageCount = 0;
    }
}